package com.pxene.dmp.mapper;

import java.io.IOException;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

public class SortFavouriteSiteMapper extends
		Mapper<LongWritable, Text, Text, Text> {
	
    private Text resultKey = new Text();
    private Text resultVal = new Text();

	@Override
	protected void map(LongWritable key, Text value, Context context)
			throws IOException, InterruptedException {
		String[] columns = value.toString().split("\\|");
		if (columns.length != 5) {
			return;
		}
		String imsi = columns[0];
		String site = columns[1];
		String sum = columns[2];
		String province = columns[3];
		String dataType = columns[4];
		
		resultKey.set(imsi + "|" + province + "|" + dataType);
		resultVal.set(site + "|" + sum);
		context.write(resultKey, resultVal);
	}
}
